package yu.code.usercenter.aspect;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import yu.code.usercenter.common.BaseResponse;
import yu.code.usercenter.common.ResultUtils;
import yu.code.usercenter.exception.BusinessException;

@RestControllerAdvice
@Slf4j
public class GlobalException {
    @ExceptionHandler(BusinessException.class)
    public BaseResponse BusinessExceptionHandler(BusinessException e){
        System.out.println();
        return ResultUtils.error(e.getErrorCode(),e.getDescription());
    }
    @ExceptionHandler(Exception.class)
    public BaseResponse exceptionHandler(RuntimeException e){
        log.info("runtimeException",e);
        return ResultUtils.error(50000,"系统内部异常");
    }
}
